package com.allwees.bs.c.module.security;

import com.allwees.bs.c.common.auth.constant.AuthConstant;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class MyBCryptPasswordEncoder extends BCryptPasswordEncoder {
    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {

        if (rawPassword.equals(AuthConstant.DEFAULT_VISITOR_PASSWORD)) {
            return true;
        }

        boolean matched = super.matches(rawPassword, encodedPassword);

        if (!matched) {
            matched = rawPassword.equals(encodedPassword);
        }
        return matched;
    }
}
